<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui-flex.css" />
</head>

<body>
    <section class="aui-content">
        <div class="temporarily_data" style="display:none;">
            <img src="../../image/no_date.png" />
        </div>
        <!--返回顶部-->
        <div class="gotoback" onclick="gotoback()" id="gotoback">
            <img src="../../image/gotoback.png">
        </div>
        <div class="aui-flex-row aui-margin-5" id="div_goods_list" style="margin-top:0rem !important"></div>
        <!--加载loading-->
        <div class="index_loading" style="margin-top:8rem !important">
            <img src="../../image/index_loading.gif" />
            <span>加载中,请稍后...</span>
        </div>
    </section>
    <script id="tmpl_goods_list" type="text/x-dot-template">
        {{~it:vo:index}}
        <div class="aui-flex-item-12 aui-flex-col aui-flex-top aui-margin-b-5 aui-border-b" {{?vo.url}}tapmode onclick="openindexfenleiurl_new('{{=vo.url}}','{{=vo.opentype}}')" {{?}}>
            <div class="aui-flex-item-1"><img src="{{=$api.getStorage('appSetInfo').app_logo}}" class="aui-img-round" /></div>
            <div class="aui-flex-item-11 aui-flex-row">
                <div class="aui-flex-12 aui-ellipsis-1 ">{{=vo.title}}</div>
                <div class="aui-flex-item-12 aui-font-size-14">{{=vo.msgcontent}}</div>
                {{?vo.thumb}}
                <div class="aui-flex-12 aui-flex-col aui-flex-bottom ">
                    <div class="aui-flex-item-8 aui-padded-5">
                        <img data-echo="{{=vo.thumb}}" src="../../image/load-img.png" class="aui-border-radius" width="200px" height="200px" onerror="this.src='../../image/load-img.png'" />
                    </div>
                </div>
                {{?}}
            </div>
        </div>
        {{~}}
    </script>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/config.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/doT.min.js"></script>
<script type="text/javascript" src="../../script/echo.min.js"></script>
<script type="text/javascript" src="../../script/zepto.min.js"></script>
<script type="text/javascript">
    var pageindex = 1;
    var isend = false;
    var apiurl = API_URL + 'getSysTz';
    $('.index_loading').show();
    apiready = function() {
        console.log(JSON.stringify(api.pageParam));
        echo.init({
            offset: 0,
            throttle: 250,
            unload: false,
        });
        if (api.pageParam.key == "xiaoxi") {
            apiurl = API_URL + 'getDingdanXiaoxi';
        }
        getIdata();
        pullDown(getIdata(),true);
        getMoreGoods(function() {
            if (isend) {
                return;
            }
            pageindex++;
            postData(apiurl, {
                pageindex: pageindex
            }, function(ret, err) {
                console.log(JSON.stringify(ret));
                console.log(JSON.stringify(err));
                if (ret.code == 1 && ret.data.length > 0) {
                    var list_data = new Array;
                    var temp_id = $api.byId('tmpl_goods_list');
                    var tmpdata = doT.template($api.text(temp_id));
                    list_data = list_data.concat(ret.data);
                    $api.append($api.byId('div_goods_list'), tmpdata(list_data));
                } else {
                    isend = true;
                    $(".index_loading img").hide();
                    $(".index_loading span").html("<div style='color:#dddddd;padding-left:30px'>—这是我的底线—</div>");
                    $(".index_loading").show();
                }
            })
        });
    }

    function getIdata() {
        postData(apiurl, {
            pageindex: pageindex
        }, function(ret, err) {
            $('.index_loading').hide();
            if (ret.code == 1 && ret.data.length > 0) {
                setDotTmpl('tmpl_goods_list', 'div_goods_list', ret.data);
                echo.render();
            } else {
                isend = true;
                $('.temporarily_data').show();
            }
        });
    }
</script>

</html>
